package com.cratos.xxgram.platf.group;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;

import org.redkale.util.Comment;
import org.redkale.util.Reproduce;
import org.redkale.util.Utility;

import com.cratos.xxgram.platf.base.BaseEntity;

/**
 *
 * @author SquRab
 */
@Table(comment = "用户群组管理")
public class UserGroup extends BaseEntity {

    @Id
    @Column(comment = "用户群组ID groupId + “-” + userId")
    private String usergroupid;

    @Column(comment = "用户ID")
    private int userid;

    @Column(comment = "群组ID")
    private int groupid;

    @Column(comment = "加入时间")
    private long jointime;
    
    @Column(comment = "聊天背景图url")
    private String chatbackground = "";
  
    @Comment("禁言")
    public static final int SYSSETTING_FORBIDDEN_WORDS_INDEX = 1;
    
    @Comment("预留 5位给系统扩展")
    public static final int SYSSETTING_GROUP_LIMIT_INDEX = 5;
    
    @Column(comment = "系统配置 第1位表示 全员禁言  第2位  群消息 回执 "
                    + "第6位表示 消息免打扰")
    private long syssetting;
    
    @Comment("用户名称")
    private String username;
     
    @Comment("用户群昵称")
    private String usernickname;
    
    @Column(comment = "用户头像")
    protected String face = "";
     
    @Comment("匿名群人员下表")
    private int annoyindex = 0;

    @Comment("对象拷贝")
    private static final Reproduce<UserGroupHis, UserGroup> copyer = Reproduce.create(UserGroupHis.class, UserGroup.class);
    
    public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	
	public String getUsernickname() {
		return usernickname;
	}

	public void setUsernickname(String usernickname) {
		this.usernickname = usernickname;
	}

	public String getFace() {
		return face;
	}

	public void setFace(String face) {
		this.face = face;
	}

	public int getAnnoyindex() {
        return annoyindex;
    }

    public void setAnnoyindex(int annoyindex) {
        this.annoyindex = annoyindex;
    }
    
  
    public String getChatbackground() {
        return chatbackground;
    }

    public void setChatbackground(String chatbackground) {
        this.chatbackground = chatbackground;
    }
    
    public long getJointime() {
        return jointime;
    }

    public void setJointime(long jointime) {
        this.jointime = jointime;
    }

    public String getUsergroupid() {
        return usergroupid;
    }

    public void setUsergroupid(String usergroupid) {
        this.usergroupid = usergroupid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public int getUserid() {
        return this.userid;
    }

    public void setGroupid(int groupid) {
        this.groupid = groupid;
    }

    public int getGroupid() {
        return this.groupid;
    }

    public long getSyssetting() {
        return syssetting;
    }

    public void setSyssetting(long syssetting) {
        this.syssetting = syssetting;
    }

    public UserGroupHis createTableHis(long now) {
    	UserGroupHis his = copyer.apply(new UserGroupHis(), this);
        his.setRemovetime(now);
        his.setSeqid(his.getUsergroupid() + "-" +Utility.format36time(now));
        return his;
    }
}
